package br.com.remedioCerto.model;

import java.io.ByteArrayOutputStream;
import java.io.Serializable;

import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;

public class Perfil implements Serializable {

	private static final long serialVersionUID = 5253651257466681382L;
	private Long id;
	private String nome;
	private byte[] foto;
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getNome() {
		return nome;
	}
	public void setNome(String nome) {
		this.nome = nome;
	}

	public byte[] getFoto() {
		return foto;
	}
	public void setFoto(byte[] foto) {
		this.foto = foto;
	}

	public Bitmap getFotoBitmap() {
		return foto==null? null : BitmapFactory.decodeByteArray(foto, 0, foto.length);
	}
	public void setFotoBitmap(Bitmap bit) {
		ByteArrayOutputStream stream = new ByteArrayOutputStream();
		bit.compress(CompressFormat.PNG, 0, stream);
		this.foto = stream.toByteArray();
	}
	
	@Override
	public String toString(){
		return nome;
	}
}
